package com.itqf.vo;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * projectName: online_QA
 *
 * @author: 李阳
 * time: 2021/7/2 0002 15:25
 * description:映射返回结果的code,msg,data
 * code  = 0 统一失败
 * code  = 1 成功
 */

public class ResultVO {


    private Integer code=0;
    private String msg="";

    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    private Object data;

    /**
     * 成功方法
     * @param msg
     * @param data
     * @return
     */
    public  static  ResultVO OK(String msg,Object data){

        return new ResultVO(1, msg, data);
    }

    /**
     * 成功方法
     * @param msg
     * @return
     */
    public  static  ResultVO OK(String msg){

        return new ResultVO(1, msg, null);
    }


    /**
     * 成功方法
     * @param data
     * @return
     */
    public  static  ResultVO OK(Object data){

        return new ResultVO(1, null, data);
    }




    /**
     * 失败方法
     * @param msg
     * @param data
     * @return
     */
    public  static  ResultVO FAIL(String msg,Object data){

        return new ResultVO(0, msg, data);
    }

    /**
     * 失败方法
     * @param msg
     * @return
     */
    public  static  ResultVO FAIL(String msg){

        return new ResultVO(0, msg, null);
    }


    /**
     * 失败方法
     * @param data
     * @return
     */
    public  static  ResultVO FAIL(Object data){

        return new ResultVO(0, null, data);
    }




    public ResultVO(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }






    public ResultVO() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}

